import unittest

import requests


class wdds(unittest.TestCase):
    host="http://10.59.9.18/"
    userId=None
    sessionId=None
    #登录
    def test_01(self):
        url=wdds.host+"/small/user/v1/login"
        json={"phone":"15385256987","pwd":"123456Aa"}
        r=requests.post(url=url,json=json)
        print(r.json())
        wdds.userId=str(r.json()['result']['userId'])
        wdds.sessionId = r.json()['result']['sessionId']
    #修改昵称
    def test_02(self):
        url=wdds.host+"small/user/verify/v1/modifyUserNick"
        json={"nickName":"冬天的猫"}
        hesder={"userId":wdds.userId,"sessionId":wdds.sessionId}
        r=requests.put(url=url,params=json,headers=hesder)
        print(r.json())
    #根据用户ID查询用户信息
    def test_03(self):
        url=wdds.host+"/small/user/verify/v1/getUserById"
        hesder={"userId":wdds.userId,"sessionId":wdds.sessionId}
        r=requests.get(url=url,headers=hesder)
        print(r.json())
    #收货地址列表
    def test_04(self):
        url=wdds.host+"small/user/verify/v1/receiveAddressList"
        hesder={"userId":wdds.userId,"sessionId":wdds.sessionId}
        r=requests.get(url=url,headers=hesder)
        print(r.json())
    #新增收货地址
    def test_05(self):
        url=wdds.host+"/small/user/verify/v1/addReceiveAddress"
        hesder={"userId":wdds.userId,"sessionId":wdds.sessionId}
        json={"realName":"吴嫣然","phone":"15385256987","address":"山东潍坊","zipCode":"101010"}
        r=requests.post(url=url,headers=hesder,params=json)
        print(r.json())
    #设置默认收货地址
    def test_06(self):
        url = wdds.host + "small/user/verify/v1/setDefaultReceiveAddress"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"id": '7161'}
        r = requests.post(url=url, headers=hesder, params=json)
        print(r.json())
    #修改收货信息
    def test_07(self):
        url = wdds.host + "small/user/verify/v1/changeReceiveAddress"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"id": '7161',"realName":"吴嫣然","phone":"15385256987","address":"山东","zipCode":"101010"}
        r = requests.put(url=url, headers=hesder, params=json)
        print(r.json())
    #查询用户钱包
    def test_08(self):
        url = wdds.host + "/small/user/verify/v1/findUserWallet"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"page": 1,"count":5}
        r = requests.get(url=url, headers=hesder, params=json)
        print(r.json())
    #删除收货地址
    # def test_09(self):
    #     url = wdds.host + "/small/user/verify/v1/deleteReceiveAddress"
    #     hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
    #     json = {"id": 7159}
    #     r = requests.delete(url=url, headers=hesder, params=json)
    #     print(r.json())
    #创建订单
    def test_10(self):
        url = wdds.host + "small/order/verify/v1/createOrder"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"orderInfo": str([{"commodityId":3,"amount":1}]),"totalPrice":"255.2","addressId":7161}
        r = requests.post(url=url, headers=hesder, params=json)
        print(r.json())
    #支付
    def test_11(self):
        url = wdds.host + "/small/order/verify/v1/pay"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"orderId":145 ,"payType":1}
        r = requests.post(url=url, headers=hesder, params=json)
        print(r.json())
    #根据订单状态查询订单信息
    def test_12(self):
        url = wdds.host + "small/order/verify/v1/findOrderListByStatus"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"status":2 ,"page":1,"count":5}
        r = requests.get(url=url, headers=hesder, params=json)
        print(r.json())
    # 删除订单
    def test_13(self):
        url = wdds.host + "small/order/verify/v1/deleteOrder"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"orderId": 2024071309410860231479, "page": 1, "count": 5}
        r = requests.delete(url=url, headers=hesder, params=json)
        print(r.json())
    #收货
    def test_14(self):
        url = wdds.host + "small/order/verify/v1/confirmReceipt"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"orderId": 2024071309410860231479}
        r = requests.put(url=url, headers=hesder, params=json)
        print(r.json())
    #查询购物车
    def test_15(self):
        url = wdds.host + "small/order/verify/v1/findShoppingCart"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"orderId": 2024071309410860231479}
        r = requests.get(url=url, headers=hesder)
        print(r.json())
    #同步购物车数据
    def test_16(self):
        url = wdds.host + "small/order/verify/v1/syncShoppingCart"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json={"data":str([{"commodityId" :5,"count":3}])}
        r = requests.put(url=url, headers=hesder,params=json)
        print(r.json())
    # #查询订单明细数据
    # def test_17(self):
    #     url = wdds.host + "/small/order/verify/v1/findOrderInfo"
    #     hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
    #     json = {"orderId": "2024071309410860231479"}
    #     r = requests.get(url=url, headers=hesder, params=json)
    #     print(r.json())
    #圈子列表
    def test_18(self):
        url = wdds.host + "/small/circle/v1/findCircleList"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json={"page":1,"count":5}
        r = requests.get(url=url, headers=hesder,params=json)
        print(r.json())
    #删除我发表过的圈子
    def test_19(self):
        url = wdds.host + "/small/circle/verify/v1/deleteCircle"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"circleId": [1,2]}
        r = requests.delete(url=url, headers=hesder, params=json)
        print(r.json())
    #我的圈子
    def test_20(self):
        url = wdds.host + "/small/circle/verify/v1/findMyCircleById"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"page": 1,"count":5}
        r = requests.get(url=url, headers=hesder, params=json)
        print(r.json())
    #圈子点赞
    def test_21(self):
        url = wdds.host + "small/circle/verify/v1/addCircleGreat"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"circleId": 1}
        r = requests.post(url=url, headers=hesder, params=json)
        print(r.json())
    #取消点赞
    def test_22(self):
        url = wdds.host + "/small/circle/verify/v1/cancelCircleGreat"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"circleId": 1}
        r = requests.delete(url=url, headers=hesder, params=json)
        print(r.json())
    #首页商品信息列表
    def test_23(self):
        url = wdds.host + "small/commodity/v1/commodityList"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"circleId": 1}
        r = requests.get(url=url)
        print(r.json())
    #根据商品列表归属标签查询商品信息
    def test_24(self):
        url = wdds.host + "small/commodity/v1/findCommodityListByLabel"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"labelId": '1001',"page":1,"count":5}
        r = requests.get(url=url,params=json)
        print(r.json())
    #商品详情
    def test_25(self):
        url = wdds.host + "small/commodity/v1/findCommodityDetailsById"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"commodityId": 19}
        r = requests.get(url=url,params=json,headers=hesder)
        print(r.json())
    #根据关键词查询商品信息
    def test_26(self):
        url = wdds.host + "small/commodity/v1/findCommodityByKeyword"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"keyword": "板鞋","page":1,"count":5}
        r = requests.get(url=url,params=json,headers=hesder)
        print(r.json())
    #根据二级类目查询商品信息
    def test_27(self):
        url = wdds.host + "small/commodity/v1/findCommodityByCategory"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"categoryId": "1001004002", "page": 1, "count": 5}
        r = requests.get(url=url, params=json, headers=hesder)
        print(r.json())
    #我的足迹
    def test_28(self):
        url = wdds.host + "small/commodity/verify/v1/browseList"
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = { "page": 1, "count": 5}
        r = requests.get(url=url, params=json, headers=hesder)
        print(r.json())
    #商品评论列表
    def test_29(self):
        url = wdds.host + 'small/commodity/v1/CommodityCommentList'
        hesder = {"userId": wdds.userId, "sessionId": wdds.sessionId}
        json = {"commodityId":19,"page": 1, "count": 5}
        r = requests.get(url=url, params=json, headers=hesder)
        print(r.json())
    #查询商品类目
    def test_30(self):
        url = wdds.host + '/small/commodity/v1/findCategory'
        r = requests.get(url=url)
        print(r.json())
    #查询推荐商品
    def test_31(self):
        url = wdds.host + '/small/commodity/v1/findRecommendCommodity'
        r = requests.get(url=url)
        print(r.json())
    #查询商品库存数量
    def test_32(self):
        url = wdds.host + 'small/commodity/v1/getInventory'
        json={"commodityId":19}
        r = requests.get(url=url,params=json )
        print(r.json())
if __name__ == '__main__':
    unittest.main()
